using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using OpenNETCF.Win32;
using System.Drawing;

namespace SIMc
{
    class NativeMethods
    {
        public delegate IntPtr WndProcDelegate(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);

        // 
        // Register the WLINKCANVAS window class. This MUST be called
        // before creating a canvas window 
        //
        [DllImport("inkctrls")]
        public static extern bool InitInkControls();

        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, out IntPtr lParam);

        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, out object lParam);

        //[DllImport("coredll")]
        //public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref PENSTYLE lParam);

        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref Size lParam);

        //[DllImport("coredll")]
        //public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref Interfaces.VARIANT v);

        [DllImport("oleaut32")]
        public extern static void VariantInit(IntPtr pv);

        [DllImport("oleaut32")]
        public extern static void VariantClear(IntPtr pv);

        //[DllImport("oleaut32")]
        //public extern static void VariantClear(ref Interfaces.VARIANT pv);

        [DllImport("oleaut32")]
        public static extern IntPtr SafeArrayCreateVector(VarEnum vt, int lb, int cElem);

        [DllImport("oleaut32")]
        public static extern int SafeArrayDestroy(IntPtr psa);

        [DllImport("oleaut32")]
        public static extern int SafeArrayAccessData(IntPtr psa, out IntPtr ppvData);

        [DllImport("oleaut32")]
        public static extern int SafeArrayUnaccessData(IntPtr psa);

        [DllImport("oleaut32")]
        public static extern int SafeArrayGetUBound(IntPtr psa, uint nDim, out int plUbound);

        [DllImport("oleaut32")]
        public static extern int SafeArrayGetLBound(IntPtr psa, uint nDim, out int plLbound);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern int SetWindowLong(IntPtr hWnd, GWL nIndex, WndProcDelegate newProc);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr GetWindowLong(IntPtr hWnd, GWL nIndex);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("coredll")]
        public static extern void mouse_event(MOUSEEVENTF dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

        [Flags()]
        public enum MOUSEEVENTF
        {
            MOVE = 0x1, /* mouse move */
            LEFTDOWN = 0x2, /* left button down */
            LEFTUP = 0x4, /*left button up */
            RIGHTDOWN = 0x8, /*right button down */
            RIGHTUP = 0x10, /*right button up */
            MIDDLEDOWN = 0x20, /*middle button down */
            MIDDLEUP = 0x40, /* middle button up */
            WHEEL = 0x800, /*wheel button rolled */
            VIRTUALDESK = 0x4000, /* map to entrire virtual desktop */
            ABSOLUTE = 0x8000, /* absolute move */
            TOUCH = 0x100000, /* absolute move */
        }
    }
}
